'''
协程模块：gevent

'''

import gevent
import time


def playGrame():
    while 1:
        print("玩游戏")
        time.sleep(2)
        g2.switch()


def listenMusic():
    while 1:
        print("听歌")
        time.sleep(2)
        g1.switch()


g1 = gevent.spawn(playGrame)
g2 = gevent.spawn(listenMusic)

gevent.joinall([g1, g2])

